home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / XAMPP 1.4.14 / xampp-win32-1.4.14-installer.exe / xampp / php / pear / DBA / Compatibility.php
PHP Script  |  2004-10-01  |  3KB  |  112 lines

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | Copyright (c) 2002-2003 Brent Cook                                        |
  5. // +----------------------------------------------------------------------+
  6. // | This library is free software; you can redistribute it and/or        |
  7. // | modify it under the terms of the GNU Lesser General Public           |
  8. // | License as published by the Free Software Foundation; either         |
  9. // | version 2.1 of the License, or (at your option) any later version.   |
  10. // |                                                                      |
  11. // | This library is distributed in the hope that it will be useful,      |
  12. // | but WITHOUT ANY WARRANTY; without even the implied warranty of       |
  13. // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    |
  14. // | Lesser General Public License for more details.                      |
  15. // |                                                                      |
  16. // | You should have received a copy of the GNU Lesser General Public     |
  17. // | License along with this library; if not, write to the Free Software  |
  18. // | Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA|
  19. // +----------------------------------------------------------------------+
  20. //
  21. // $Id: Compatibility.php,v 1.10 2003/01/04 11:54:51 mj Exp $
  22.  
  23. /** 
  24.  * dba compatibility layer
  25.  * This works in reverse of the rest of the DBA classes. If you have code
  26.  * that requires the PHP dba functions, but are using a system where they
  27.  * are not available, including this file will define a set for you.
  28.  * See the PHP documentation on dba for explanation of how these functions
  29.  * work.
  30.  *
  31.  * @author Brent Cook <busterb@mail.utexas.edu>
  32.  * @version 1.0
  33.  * @access public
  34.  * @package DBA
  35.  * @see PHP dba Documentation
  36.  */
  37.  
  38. if (!function_exists('dba_open')) {
  39.  
  40.     require_once 'PEAR.php';
  41.     require_once 'DBA/Driver/File.php';
  42.  
  43.     function dba_close(&$dba)
  44.     {
  45.         $result = !PEAR::isError($dba->close());
  46.         unset($dba);
  47.         return $result;
  48.     }
  49.  
  50.     function dba_delete($key, &$dba)
  51.     {
  52.         return !PEAR::isError($dba->remove($key));
  53.     }
  54.  
  55.     function dba_exists($key, &$dba)
  56.     {
  57.         return !PEAR::isError($dba->exists($key));
  58.     }
  59.  
  60.     function dba_fetch($key, &$dba)
  61.     {
  62.         return !PEAR::isError($dba->fetch($key));
  63.     }
  64.  
  65.     function dba_firstkey(&$dba)
  66.     {
  67.         return $dba->firstkey();
  68.     }
  69.  
  70.     function dba_insert($key, $value, &$dba)
  71.     {
  72.         return !PEAR::isError($dba->insert($key, $value));
  73.     }
  74.  
  75.     function dba_nextkey(&$dba)
  76.     {
  77.         return $dba->nextkey();
  78.     }
  79.  
  80.     function dba_open($filename, $mode, $handler)
  81.     {
  82.         $dba = new DBA_Driver_File();
  83.         $dba->open($filename, $mode);
  84.         if (PEAR::isError($dba)) {
  85.             return false;
  86.         } else {
  87.             return $dba;
  88.         }
  89.     }
  90.  
  91.     function dba_popen(&$dba)
  92.     {
  93.         return FALSE;
  94.     }
  95.  
  96.     function dba_replace($key, $value, &$dba)
  97.     {
  98.         return !PEAR::isError($dba->replace($key, $value));
  99.     }
  100.  
  101.     function dba_sync(&$dba)
  102.     {
  103.         $dba->sync();
  104.     }
  105.  
  106.     function dba_optimize(&$dba)
  107.     {
  108.         $dba->optimize();
  109.     }
  110. }
  111. ?>
  112.